Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use libc::strerror_r instead of our own definition #85

Merged
merged 1 commit into from
Nov 1, 2023

Conversation

taiki-e
Copy link
Contributor

@taiki-e taiki-e commented Nov 1, 2023

We already depend on libc to use strlen, and libc provides strerror_r for all unix/wasi platforms we support.

(As for errno_location, it seems that libc does not provide a corresponding one for some platforms yet.)

@taiki-e
Copy link
Contributor Author

taiki-e commented Nov 1, 2023

for all unix/wasi platforms we support.

FYI, the following is a script I used to check this.

#!/bin/bash

targets=(
    # src/windows.rs
    x86_64-pc-windows-msvc
    x86_64-pc-windows-gnu
    # src/wasi.rs
    wasm32-wasi
    # src/unix.rs
    aarch64-apple-ios
    i686-unknown-hurd-gnu
    powerpc64-ibm-aix
    riscv32imc-esp-espidf
    x86_64-apple-darwin
    x86_64-linux-android
    x86_64-pc-nto-qnx710
    x86_64-pc-solaris
    x86_64-unknown-dragonfly
    x86_64-unknown-freebsd
    x86_64-unknown-haiku
    x86_64-unknown-hermit
    x86_64-unknown-illumos
    x86_64-unknown-linux-gnu
    x86_64-unknown-linux-musl
    x86_64-unknown-netbsd
    x86_64-unknown-openbsd
    x86_64-unknown-redox
)

# Use -Z build-std for tier 3 targets.
rustup component add rust-src

for target in "${targets[@]}"; do
    if rustup target add "${target}" &>/dev/null; then
        cargo build --no-default-features --target "${target}"
    else
        cargo build --no-default-features -Z build-std=core --target "${target}"
    fi
done

@sunfishcode
Copy link
Collaborator

It does appear that the libc crate version has the needed __xpg_strerror_r attribute, so this looks good.

@sunfishcode sunfishcode merged commit 235907b into lambda-fairy:main Nov 1, 2023
11 checks passed
@taiki-e taiki-e deleted the libc branch November 1, 2023 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants